﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MMS.UI.Extension
{
    /// <summary>
    /// 实体类 的扩展方法
    /// </summary>
    public static class ModelExtension
    {
        #region 1.0 将 会员等级实体 对象 转成会员等级视图模型 对象
        /// <summary>
        /// 将 会员等级实体 对象 转成会员等级视图模型 对象
        /// </summary>
        /// <param name="poco"></param>
        /// <returns></returns>
        public static MMS.UI.Areas.Admin.ViewModels.LevelModel ToViewModel(this Model.Level poco)
        {
            return new MMS.UI.Areas.Admin.ViewModels.LevelModel()
            {
                LName = poco.LName,
                LDiscount = poco.LDiscount,
                LIntegralRatio = poco.LIntegralRatio,
                LUpGradeAmount = poco.LUpGradeAmount,
                LRemark = poco.LRemark

            };
        }
        #endregion

        #region 2.0 将 会员实体 对象 转成会员视图模型 对象
        /// <summary>
        /// 将 会员实体 对象 转成会员视图模型 对象
        /// </summary>
        /// <param name="poco"></param>
        /// <returns></returns>
        public static MMS.UI.Areas.Admin.ViewModels.MemberInfoModel ToViewModel(this Model.MemberInfo poco)
        {
            return new MMS.UI.Areas.Admin.ViewModels.MemberInfoModel()
            {
                MAddress = poco.MAddress,
                MBalances = poco.MBalances,
                MBirthday = poco.MBirthday,
                MCardId = poco.MCardId,
                MConsumption = poco.MConsumption,
                MEmail = poco.MEmail,
                MGender = poco.MGender,
                MId = poco.MId,
                MIntegral = poco.MIntegral,
                MLId = poco.MLId,
                MName = poco.MName,
                MOccupation = poco.MOccupation,
                MPassword = poco.MPassword,
                MPhone = poco.MPhone,
                MRemark = poco.MRemark,
                MWechat = poco.MWechat
            };
        }
        #endregion

        #region 3.0 将 商品信息实体 对象 转成商品信息视图模型 对象
        /// <summary>
        /// 将 商品信息实体 对象 转成商品信息视图模型 对象
        /// </summary>
        /// <param name="poco"></param>
        /// <returns></returns>
        public static MMS.UI.Areas.Admin.ViewModels.GoodsInfoModel ToViewModel(this Model.GoodsInfo poco)
        {
            return new MMS.UI.Areas.Admin.ViewModels.GoodsInfoModel()
            {
                GId = poco.GId,
                GCId = poco.GCId,
                GCostPrice = poco.GCostPrice,
                GSellPrice = poco.GSellPrice,
                GIntegralRatio = poco.GIntegralRatio,
                GRemark = poco.GRemark,
                GInmax = poco.GInmax,
                GInmin = poco.GInmin,
                GInventory = poco.GInventory,
                GName = poco.GName
            };
        }
        #endregion

        #region 3.0 将 销售策略信息实体 对象 转成销售策略信息视图模型 对象
        /// <summary>
        /// 将 销售策略信息实体 对象 转成销售策略信息视图模型 对象
        /// </summary>
        /// <param name="poco"></param>
        /// <returns></returns>
        public static MMS.UI.Areas.Admin.ViewModels.SalesPromotionModel ToViewModel(this Model.SalesPromotion poco)
        {
            return new MMS.UI.Areas.Admin.ViewModels.SalesPromotionModel()
            {
                SId = poco.SId,
                SMinMoney = poco.SMinMoney,
                SMaxMoney = poco.SMaxMoney,
                SIntegral = poco.SIntegral,
                SBeginTime = poco.SBeginTime,
                SEndTime = poco.SEndTime,
                SPlace = poco.SPlace,
                SRemark = poco.SRemark,
            };
        }
        #endregion
    }
}